package com.ruoyi.project.gxgw_modules.feedback.controller;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.gxgw_modules.feedback.domain.FeedbackVO;
import com.ruoyi.project.gxgw_modules.feedback.service.IFeedbackService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 用户反馈 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-01-21
 */
@Controller
@RequestMapping("/gxgw_modules/feedback")
public class FeedbackController extends BaseController
{
    private String prefix = "gxgw_modules/feedback";
	
	@Autowired
	private IFeedbackService feedbackService;
	
	@RequiresPermissions("gxgw_modules:feedback:view")
	@GetMapping()
	public String feedback()
	{
	    return prefix + "/feedback";
	}
	
	/**
	 * 查询用户反馈列表
	 */
	@RequiresPermissions("gxgw_modules:feedback:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(FeedbackVO feedback)
	{
		startPage();
        List<FeedbackVO> list = feedbackService.selectFeedbackList(feedback);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出用户反馈列表
	 */
	@RequiresPermissions("gxgw_modules:feedback:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FeedbackVO feedback)
    {
    	List<FeedbackVO> list = feedbackService.selectFeedbackList(feedback);
        ExcelUtil<FeedbackVO> util = new ExcelUtil<>(FeedbackVO.class);
        return util.exportExcel(list, "feedback");
    }
	
	/**
	 * 新增用户反馈
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	*//**
	 * 新增保存用户反馈
	 *//*
	@RequiresPermissions("gxgw_modules:feedback:add")
	@Log(title = "用户反馈", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Feedback feedback)
	{		
		return toAjax(feedbackService.insertFeedback(feedback));
	}

	*//**
	 * 修改用户反馈
	 *//*
	@GetMapping("/edit/{fbId}")
	public String edit(@PathVariable("fbId") Integer fbId, ModelMap mmap)
	{
		Feedback feedback = feedbackService.selectFeedbackById(fbId);
		mmap.put("feedback", feedback);
	    return prefix + "/edit";
	}
	
	*//**
	 * 修改保存用户反馈
	 *//*
	@RequiresPermissions("gxgw_modules:feedback:edit")
	@Log(title = "用户反馈", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Feedback feedback)
	{		
		return toAjax(feedbackService.updateFeedback(feedback));
	}
	*/
	/**
	 * 删除用户反馈
	 */
	@RequiresPermissions("gxgw_modules:feedback:remove")
	@Log(title = "用户反馈", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(feedbackService.deleteFeedbackByIds(ids));
	}
	
}
